home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / GC / mark_roots.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-25  |  1.6 KB  |  61 lines

  1. # include <stdio.h>
  2. # include "gc.h"
  3.  
  4. /* Call the mark routines (tl_mark for a single pointer, mark_all */
  5. /* on groups of pointers) on every top level accessible pointer.  */
  6. /* This is source language specific.  The following works for C.  */
  7.  
  8. mark_roots()
  9. {
  10.     int * dummy = 0;
  11.     long sp_approx = 0;
  12.  
  13.     /*
  14.      * mark from registers - i.e., call tl_mark(i) for each
  15.      * register i
  16.      */
  17.     mark_regs(ALIGNMENT); /* usually defined in machine_dep.c */
  18.  
  19. #       ifdef DEBUG
  20.         printf("done marking from regs - calling mark_all\n");
  21. #    endif
  22.  
  23.       /* put stack pointer into sp_approx            */
  24.       /* and mark everything on the stack.           */
  25.     /* A hack */
  26.     sp_approx = ((long)(&dummy));
  27.     mark_all( sp_approx, stacktop, ALIGNMENT );
  28.  
  29.  
  30.     /* Mark everything in data and bss segments.                             */
  31.     /* Skip gc data structures. (It's OK to mark these, but it wastes time.) */
  32.     {
  33.         extern char etext, end;
  34.  
  35.         mark_all(DATASTART, begin_gc_arrays, ALIGNMENT);
  36.         mark_all(end_gc_arrays, &end, ALIGNMENT);
  37.     }
  38. }
  39.  
  40.  
  41. /* Top level mark routine. Mark from the object pointed to by p.       */
  42. /* This is defined here, since alignment is not an explicit parameter. */
  43. /* Thus the routine is language specific.                              */
  44. /* Tl_mark is normally called by mark_regs, and thus must be defined.  */
  45. void tl_mark(p)
  46. word * p;
  47. {
  48.     word * q;
  49.  
  50.     q = p;
  51.     mark_all(&q, (&q)+1, ALIGNMENT);
  52. }
  53.  
  54. /* Interface to mark_all that does not require alignment parameter.  */
  55. /* Defined here to keep mach_dep.c programming language independent. */
  56. void tl_mark_all(b,t)
  57. word *b, *t;
  58. {
  59.     mark_all(b, t, ALIGNMENT);
  60. }
  61.